package com.gjy.mongo.sp;

import lombok.Builder;
import lombok.Data;
import org.joda.time.LocalDateTime;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-01-30 10:32:18
 */
@Data
@Builder
@Document(collection = "book")
@CompoundIndexes({
        @CompoundIndex(name = "idx_category_publishDate", def = "{'category':1,'publishDate':1}")
})
public class Book extends BaseAuditable{

    @Id
    private String id;
    @Indexed
    private String author;
    private String category;
    @Indexed(unique = true)
    private String title;
    private Integer voteCount;
    private LocalDateTime publishDate;
}
